<!-- 
    Copyright (C)  2011  chen wei hua.
    Permission is granted to copy, distribute and/or modify this document
    under the terms of the GNU Free Documentation License, Version 2.0
    or any later version published by the Free Software Foundation;
    with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
    A copy of the license is included in the section entitled "GNU Free Documentation License".
 -->
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="../../../common/jsp/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>结算管理-新建库存盘点计划</title>
<style type="text/css">
.marginLeft {
	margin-left:10px;
}
</style>
<%@ include file="../../../common/jsp/config.jsp"%>
<%@ include file="../../../common/jsp/validate.jsp"%>
<script type="text/javascript" src="common/js/calendar/WdatePicker.js" ></script>
<script type="text/javascript">
    
    function jsonDataCallback(json) {
        var checkBoxs = $("#productCategorysDiv");
        checkBoxs.html("");
        var list = json.categoryList;
        $.each(list, function(i, o) {
        	var checkbox = $("<input type='checkbox' value='" + o.id + "'/>");
        	checkbox.attr("txtValue", o.name);
        	if ($("#span-" + o.id).length > 0) {
        		checkbox.attr("checked", true);
        	}
	       	checkBoxs.append(checkbox);
	       	checkBoxs.append("<label>" + o.name + "</label>");
        });
    }
    
	$(document).ready(function() {
		$("#saveCustomer").validate();
		$("#root_category").bind("change", function() {
			var parentId = $(this).val();
			var url="queryMaterialsCategoryJOSN.action?categoryId=" + parentId + "&temp=" + new Date();
			$.getJSON(url, jsonDataCallback);
		});
		var checkBoxs = $("#productCategorysDiv");
		var resultBoxs = $("#selectProductCategorysDiv");
		checkBoxs.click(function(e){
			if (e.target.type && e.target.type == "checkbox") {
				var select = $(e.target);
				if (select.attr("checked")) {
					var span = $("<span id='span-" + select.val() + "' class='marginLeft'>" + select.attr("txtValue")
							+ "<input type='hidden' name='selectCategoryIds' value='" + select.val() + "' /></span>");
					resultBoxs.append(span);
				} else {
					$("#span-" + select.val()).remove();
				}
	        }
		});
	});
	
	function querySubmit() {
    	$("#queryMaterialsInventoryInfo").submit();
	}
	function saveCheck() {
		$("#queryMaterialsInventoryInfo").attr("action", "saveInventoryCheckInfo.action");
    	$("#queryMaterialsInventoryInfo").submit();
    	self.returnValue = DIALOG_RESULT_TYPE_SUCCESS;
    	self.close();
	}
</script>
</head>
<base target="_self">
<body>
    <div class="subnav" align="left">
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
		  <tr>
			<td width="100%" align="left" height="31">&nbsp;<img src="common/images/title-pk.gif" border="0"  align="absmiddle"/>&nbsp;<span class="subnavtxt1">结算管理</span>
			&nbsp;<img src="common/images/leftico2.gif" border="0"  align="absmiddle"/>&nbsp;<span class="subnavtxt2">新建库存盘点计划</span></td>
		  </tr>
		</table>
      </div>
     <s:fielderror />
   <div class="divborder">
      <s:form action="queryMaterialsInventoryInfo">
        <table width="100%" border="0" cellspacing="1" cellpadding="3">
          <tr>
            <td width="10%" align="right">日期</td>
            <td width="15%">
				<s:textfield name="queryDate" onclick="WdatePicker({dateFmt:'yyyy-MM'})" readonly="true" size="10" />
			</td>
            <td width="10%" align="right">分类</td>
            <td width="15%">
              <s:if test="rootCategoryList!=null">
			  <s:select id="root_category"
          		name="rootCategory"
          		list="rootCategoryList"
          		listKey="id"
          		listValue="name"
          		headerKey="-1"
          		headerValue="-请选择-" />
          	  </s:if>
			</td>
            <td width="10%" align="right">已选分类</td>
            <td width="20%"> 
			  <div id="selectProductCategorysDiv" style="width:100%; height:100%">
			    <s:iterator value="selectCategorys" id="category" status="st">
			        <span id='span-<s:property value="#category.id" />' class="marginLeft">
					  <s:property value="#category.name" />
					  <s:hidden name="selectCategoryIds" value="%{#category.id}" />
			        </span>
			    </s:iterator>
			  </div>
           </td>
           <td width="10%" align="right">
		    <input name="button" type="button" class="input1" value="查 询" onclick="querySubmit()"/>
		   </td>
		   <td width="10%" align="right">
		    <input name="button" type="button" class="input1" value="保 存" onclick="saveCheck()"/>
		   </td>
          </tr>
    	  <tr>
    		<td colspan="3">&nbsp;</td>
    		<td colspan="5">
    			<div id="productCategorysDiv" />
    		</td>
    	  </tr>
        </table>
      </s:form>
    </div>
    <div class="clear"></div>
    <div class="main_scroll_long">
      <table width="750px" cellpadding="0" cellspacing="1" border="0" class="ksglxx2a">
        <tr class="ksglxx2bg">
          <th width="50px" >大分类</th>
          <th width="60px" >中分类</th>
          <th width="95px" >名称</th>
          <th width="120px" >型号</th>
          <th width="120px" >其他</th>
		  <th width="50px">单位</th>
		  <th width="50px">批次</th>
		  <th width="60px">合格数</th>
		  <th width="60px">不合格数</th>
		</tr>
		<s:iterator value="checkDetails" id="detail" status="st">
	      <s:if test="#st.Odd">
	        <tr class="odd">
	      </s:if >
	      <s:else>
	        <tr class="even">
	      </s:else>
              <td><s:property value="#detail.skuDetail.materials.rootCategory.name" /></td>
              <td><s:property value="#detail.skuDetail.materials.category.name" /></td>
              <td><s:property value="#detail.skuDetail.materials.name" /></td>
              <td><s:property value="#detail.skuDetail.materials.type" /></td>
              <td><s:property value="#detail.skuDetail.customFieldCombox" /></td>
              <td><s:property value="#detail.skuDetail.materials.units" /></td>
              <td><s:property value="#detail.batchNo" /></td>
              <td><s:property value="#detail.number" /></td>
              <td><s:property value="#detail.defectiveNumber" /></td>
	        </tr>
	    </s:iterator>
       </table>
    </div>
</body>
</base>
</html>
